local skill = fk.CreateSkill{
  name = "tea__zhidai&",
}
local U = require "packages/utility/utility"
---@type ViewAsSkillSpec
local zhidai = {
  mute = true,
  anim_type = "special",
  interaction = function(self, player)
    local all_names = {}
    if table.contains(Self:getTableMark("@tea__zhidai_mark-phase"), "zhidai_red_viewas") then
      table.insert(all_names, "slash")
    end
    if table.contains(Self:getTableMark("@tea__zhidai_mark-phase"), "zhidai_black_viewas") then
      table.insert(all_names, "analeptic")
    end
    local names = player:getViewAsCardNames("tea__zhidai", all_names)
    if #names > 0 then
      return UI.ComboBox { choices = names, all_choices = all_names }
    end
  end,
  card_filter = function(self, player, to_select, selected)
    if #selected == 0 then
      local colors = {}
      local mark = Self:getTableMark("@tea__zhidai_mark-phase")
      if self.interaction.data == "slash" and Fk:getCardById(to_select).color == Card.Red then
        return table.contains(mark, "zhidai_red_viewas")
      elseif self.interaction.data == "analeptic" and Fk:getCardById(to_select).color == Card.Black then
        return table.contains(mark, "zhidai_black_viewas")
      end
    end
  end,
  before_use =function (self, player, use)
    player.room:notifySkillInvoked(player, "tea__zhidai_active")
  end,
  view_as = function(self, player, cards)
    if #cards ~= 1 or not self.interaction.data then return end
    local card = Fk:cloneCard(self.interaction.data)
    card:addSubcards(cards)
    card.skillName = skill.name
    return card
  end,
  enabled_at_play = function(self, player)
    return player:getMark("@tea__zhidai_mark-phase") ~= 0
  end,
}
skill:addEffect("viewas", zhidai)
return skill